package com.dormitory.controller;

import com.dormitory.bean.DormitoryBean;
import com.dormitory.bean.NewsBean;
import com.dormitory.bean.NotificationBean;
import com.dormitory.httpHelper.HttpAddNews;
import com.dormitory.httpHelper.HttpAddNotification;
import com.dormitory.httpHelper.HttpGetInfo;

import org.json.JSONException;

import java.io.IOException;
import java.util.List;

/**
 * Created by JHF on 2017/10/19.
 */

public class NewsController {
    private static NewsController _newsController;
    public static NewsController getInstance() {
        if(_newsController == null) {
            _newsController = new NewsController();
        }
        return _newsController;
    }
//    public NewsBean getNews(int id) throws IOException, JSONException {
//        return HttpGetInfo.getNews(id);
//    }
public List<NewsBean> getNews() throws IOException, JSONException {
    return HttpGetInfo.getNews();
}
    public int addnews(String content,String username) {
        try {
            return HttpAddNews.AddNewsByGet(content, username);
        } catch (Exception e) {
            e.printStackTrace();
            return 2;
        }
    }

}
